local qingjiaol = fk.CreateSkill {
  name = "qingjiaol",
}

qingjiaol:addEffect("viewas", {
  anim_type = "control",
  prompt = function(self, selected, selected_cards)
    if self.interaction.data == "sincere_treat" then
      return "#qingjiaol-sincere_treat"
    elseif self.interaction.data == "looting" then
      return "#qingjiaol-looting"
    end
  end,
  interaction =function (self)
    local names = {}
    for _, name in ipairs({"sincere_treat", "looting"}) do
      if Self:getMark("qingjiaol_"..name.."-phase") == 0 then
        table.insert(names, name)
      end
    end
    return U.CardNameBox {choices = names}
  end,
  handly_pile = true,
  card_filter = function(self, to_select, selected)
    return #selected == 0
  end,
  view_as = function(self, cards)
    if #cards ~= 1 or not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = self.name
    card:addSubcard(cards[1])
    return card
  end,
  before_use = function(self, player, use)
    player.room:setPlayerMark(player, "qingjiaol_"..use.card.name.."-phase", 1)
  end,
  enabled_at_play = function(self, player)
    return player:getMark("qingjiaol_sincere_treat-phase") == 0 or player:getMark("qingjiaol_looting-phase") == 0
  end,
})
qingjiaol:addEffect("prohibit", {
  is_prohibited = function(self, from, to, card)
    if table.contains(card.skillNames, "qingjiaol") then
      if card.name == "sincere_treat" then
        return to:getHandcardNum() <= from:getHandcardNum()
      elseif card.name == "looting" then
        return to:getHandcardNum() >= from:getHandcardNum()
      end
    end
  end,
})
return qingjiaol